package com.thoughtworks.jspecsupport;

import org.junit.Test;

import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;

public class LoadStatementMatcherTest {

    @Test
    public void should_check_and_match_load_statement() {
        LoadStatementMatcher matcher = new LoadStatementMatcher();

        String[][] testData = new String[][]{
                {"load('spec.js');", "spec.js"},
                {"   load('spec.js');  ", "spec.js"},
                {"load('spec.js')", "spec.js"},
                {"load(\"spec.js\");", "spec.js"},
                {"load(\"spec.js\")", "spec.js"},
                {"    load(\"spec.js\")   ", "spec.js"},
                {"load('jquery-min.1.3.2.js');", "jquery-min.1.3.2.js"},
                {"load('jquery-min.1.3.2.js')", "jquery-min.1.3.2.js"},
                {"load(\"jquery-min.1.3.2.js\");", "jquery-min.1.3.2.js"},
                {"load(\"jquery-min.1.3.2.js\")", "jquery-min.1.3.2.js"}

        };

        for (String[] data : testData) {
            assertTrue(data[0] + " should be matched as a load statement.", matcher.isMatch(data[0]));
            assertEquals(data[1], matcher.match(data[0]));
        }
    }

}
